FUNCTION_BLOCK LCB_Speed_sToSpeed_v 
TITLE = 'LCB_Speed_sToSpeed_v'

// This FB converts a 3-bit speed signal into a 16-bit speed signal.
//
// Versionshistory:
// 1.0 Ersterstellung R.Enders   

VERSION : '1.0'
AUTHOR  : 'Lenze'
FAMILY  : 'LCB'
NAME : 'SsToSv' // ( 8 Zeichen max.)
KNOW_HOW_PROTECT

VAR_INPUT
    diIn_s    : DINT;
END_VAR
VAR_OUTPUT
    iOut_v    : INT;
END_VAR
VAR
    tmp1:INT;
    tmp2:DWORD; 
 END_VAR

BEGIN

tmp2:= DINT_TO_DWORD (diIn_s);
tmp2:= SHR ( IN:=tmp2,N:=12);
tmp1:= DWORD_TO_INT (tmp2);
iOut_v := LIMIT (MN:= -32767, IN:= tmp1, MX:= 32767);

END_FUNCTION_BLOCK

